import React from "react";
import { Route, Switch, Link } from "react-router-dom";

class child extends React.Component {
  constructor(props) {
    super(props);
    this.state = {};
  }
  render() {
    console.log(this.props.routes, "props");
    return (
      <div>
        我是 child
        <Link to={{ pathname: "/child/childRoute" }}>
          childRoute嵌套路由
        </Link>
        <div>
           
            <Switch>
              {this.props.routes.map((item, index) => {
                return (
                  <Route
                    key={index}
                    path={item.path}
                    component={item.component}
                  />
                );
              })}
            </Switch>
         
        </div>
      </div>
    );
  }
}

export default child;
